package com.lzh.others.collection.List;

import cn.hutool.core.codec.Base64;
import com.lzh.runke.core.web_base.constant.StringConstant;
import com.lzh.runke.core.web_base.helper.UUIDHelper;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.regex.Pattern;

public class ListTest01 {

    public static boolean validateInput(String input) {
        String pattern = "^(?:[0-9]|X|D)[A-Za-z0-9]{0,49}$";
        Pattern regex = Pattern.compile(pattern);
        return regex.matcher(input).matches();
    }

    private static String uploadFile(String base64Str, String suffix, String oldFileName) {
        if (base64Str == null || base64Str.isEmpty()) {
            return null;
        }
        if (suffix == null || suffix.isEmpty()) {
            return null;
        }
        // 解码 Base64 字符串为字节数组
        byte[] decodedBytes = Base64.decode(base64Str);
        String originalName = UUIDHelper.randomUUID() + StringConstant.DOT + suffix;
        try {
            // 创建一个文件
            File tempFile = File.createTempFile(originalName, null);
            // 将字节数组写入到文件
            try (FileOutputStream fos = new FileOutputStream(tempFile)) {
                fos.write(decodedBytes);
            }
            // 删除临时文件
//            tempFile.delete();
            return null;
        } catch (IOException e) {
//            log.error("{}: {}", e.getMessage(), ExceptionUtils.getStackTrace(e));
        }
        return null;
    }


    public static void main(String[] args) {
        String base64 = "";
    }
}
